/**
 * @author 35326
 * 2021/3/16 7:02
 * 和线程中断有关的三个方法
 */
public class InterruptTest {
    public static void main(String[] args) {
        Thread t1=new Thread(){
            @Override
            public void run() {
                while(true){
                    if(Thread.currentThread().isInterrupted()){
                        System.out.println("Interrpted!!");
                        break;
                    }
                    Thread.yield();
                }
            }
        };

        t1.start();

        try {
            Thread.sleep(2000);
        } catch (InterruptedException e) {
            e.printStackTrace();
        }

        t1.interrupt();
    }
}
